import numpy as np
import pandas as pd
from sklearn import preprocessing
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier()
data=np.array(np.random.random(size=(4,2)))
num=int(len(data))
a=int(num*0.8)
# 按百分比80训练
x_train=data[0:a] #训练集
y_train=data[0:a]
x_test=data[0:(num-a)] # 测试集
y_test=data[0:(num-a)]
a=knn.fit(x_train,y_train.astype('int'))
print(a)